package com.agg.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
public class TestController {
    @RequestMapping("/")
    public String test(){


        return "/index";
    }

    @RequestMapping("/servletAPI")
    public String test1(HttpServletRequest request){
        request.setAttribute("name","这个是原生的servletAPI");

        return "/success";
    }
    @RequestMapping("/ModelAndView")
    public ModelAndView test2(){
        ModelAndView mv = new ModelAndView();
        mv.addObject("mvname","这个是ModelAndView对象");
        mv.setViewName("/success");
        return mv;
    }

    @RequestMapping("/map")
    public String test3(Map<String, Object> map){
       map.put("map","这个是map对象");
       return "/success";
    }

}
